home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1995 January / 1995-01b.d64 / life inst (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  7KB  |  186 lines

  1. 10 print"[147][152]";:poke53281,15:poke53280,15
  2. 20 fori=1to23:reada$:ifa$="[157]"thengosub80:goto200
  3. 50 printa$:next:gosub80:goto20
  4. 80 p=p+1:print" [154] [208]ress <[211][208][193][195][197]> to continue   [208]age"p"[157] [145][152]"
  5. 90 getb$:ifb$=""then90
  6. 100 print"[147]";:return
  7. 200 print"[147]     [208]ress <[209]> to [209][213][201][212]
  8. 210 [153]"cont     (NULL)ress <(NULL)> to (NULL)val(NULL)right$val(NULL)
  9. 220 print"[152]     [208]ress <[204]> to load [204][201][198][197]
  10. 240 [161]k$:[139]k$[179][177]"r"[175]k$[179][177]"l"[175]k$[179][177]"q"[167]240
  11. 250 [139]k$[178]"r"[167][138]
  12. 260 [139]k$[178]"q"[167][153]"def  valnjoy the programs and hug someone!print#":[128]
  13. 300 f$[178]"life":[153]"loadlistloadf$,8print#":[151]198,2:[151]631,19:[151]632,131:[128]
  14. 10000 [131]"
  15. 10010 data"[154]           [212]he [199]ame of [204]ife",
  16. 10030 data"    [211]imulations of [194]irth and [196]eath
  17. 10040 [131]"    right$n a lenlosed  lenomputer (NULL)niverse",
  18. 10060 [131]"print#(NULL)right$ascval is a fascinating game devised by
  19. 10070 data"mathametican [202]ohn [200]. [195]onway, and 
  20. 10080 [131]"introduced in the '(NULL)athematical chr$ames' 
  21. 10090 data"column of [211]cientific [193]merican in 1970. 
  22. 10100 [131]"right$t is not a game at all in the usual 
  23. 10110 data"sense.",
  24. 10130 data"[204]ife can be visualized as a simulation 
  25. 10140 [131]"of the history of a colony of organisms
  26. 10150 data"which occupy the squares of a grid like
  27. 10160 [131]"checkers on a checker board.
  28. 10170 data"
  29. 10180 [131]"valach square can be occupied by one 
  30. 10190 data"organism, or cell. [211]ince each square is
  31. 10200 [131]"surrounded by eight neighboring 
  32. 10210 data"squares, each cell can have up to eight
  33. 10220 [131]"neighbors. (NULL)ules for the survival of 
  34. 10230 data"cells make the colony of cells 
  35. 10240 [131]"unpredictable.",
  36. 10260 [131]"(NULL)urvival of cells can be expressed in 
  37. 10270 data"the following two rules:
  38. 10280 [131]"  1. (NULL)urvival: valach cell with either 
  39. 10290 data"two or three neighbors survives to the 
  40. 10300 [131]"next generation.
  41. 10310 data"  2. [194]irth: [193] cell is born in each 
  42. 10320 [131]"empty area with exactly three 
  43. 10330 data"neighbors.",
  44. 10350 data"[194]irths and deaths take place 
  45. 10360 [131]"simultaneously so that the population 
  46. 10370 data"of one generation will determine the 
  47. 10380 [131]"population of the next generation.",
  48. 10400 [131]"(NULL)he obvious implication of the rule of 
  49. 10410 data"survival is that cells which have more 
  50. 10420 [131]"than three neighbors will die. 
  51. 10430 data"[212]herefore, either overpopulation or 
  52. 10440 [131]"isolation is fatal to cells.",
  53. 10460 [131]"(NULL)he rule of birth dictates that the
  54. 10470 data"population density must be ideal for 
  55. 10480 [131]"birth to occur.",
  56. 10500 [131]"peeky applying these simple rules and an 
  57. 10510 data"initial colony of a few cells, 
  58. 10520 [131]"extraordinary and elaborate colonies 
  59. 10530 data"will emerge.",
  60. 10550 data"[195]olonies can grow to immense 
  61. 10560 [131]"proportions only to recede and die out 
  62. 10570 data"entirely. [211]ome colonies reach a steady 
  63. 10580 [131]"state in which no cells die and no new 
  64. 10590 data"cells are born. [207]ther colonies devolop 
  65. 10600 [131]"into patterns which repeat over a 
  66. 10610 data"period of two or more generations. 
  67. 10620 [131]"(NULL)hese oscillating patterns can be 
  68. 10630 data"objects of beautifully animated 
  69. 10640 [131]"symmetry and sometimes produce 
  70. 10650 data"surprising results.",,,
  71. 10670 data"[154][200][207][215] [212][207] [208][204][193][217] [192]",
  72. 10690 data"[152][215]hen the program is run, the word
  73. 10700 [131]"'(NULL)right$ascval' is displayed on the screen. (NULL)his
  74. 10710 data"word then becomes a life colony, which 
  75. 10720 [131]"you can watch for 232 generations. (NULL)he 
  76. 10730 data"sequence then repeats. [217]ou can press 
  77. 10740 [131]"the '(NULL)' key at any time to see the 
  78. 10750 data"instructions.",
  79. 10770 data"[212]here are two basic modes of operation 
  80. 10780 [131]"in the program. (NULL)ne is the str$(NULL)atn(NULL) mode 
  81. 10790 data"which allows you to put an initial 
  82. 10800 [131]"colony on the screen. (NULL)he other is the 
  83. 10810 data"[210][213][206] mode in which the computer 
  84. 10820 [131]"calculates and displays successive 
  85. 10830 data"generations of cells.",
  86. 10850 data"[217]ou can use the [195][213][210][211][207][210] keys or [202][207][217][211][212][201][195][203]
  87. 10860 [131]"(port 2) to draw on the screen in the 
  88. 10870 data"[196][210][193][215] mode. [212]he [210][197][212][213][210][206] key or fire 
  89. 10880 [131]"button turns the drawing on and off. 
  90. 10890 data"[217]ou can press [204] to turn the lines on 
  91. 10900 [131]"and off. (NULL)he function keys control 
  92. 10910 data"other drawing options. [208]ress [198]1 to 
  93. 10920 [131]"clear the screen, asc3 to change the 
  94. 10930 data"color of the grid and [198]5 to see the 
  95. 10940 [131]"instructions. (NULL)ress asc7 to go to the (NULL)(NULL)(NULL)
  96. 10950 data"mode. [212]he function keys perform 
  97. 10960 [131]"different operations in the (NULL)(NULL)(NULL) mode. 
  98. 10970 data"[212]hey are displayed at the bottom of the
  99. 10980 [131]"screen. (NULL)ress asc7 to (NULL)(NULL)(NULL)(NULL) and (NULL)(NULL)(NULL). (NULL)he 
  100. 10990 data"colony is not erased when you press [198]1 
  101. 11000 [131]"and return to the str$(NULL)atn(NULL) mode. (NULL)his 
  102. 11010 data"allows you to modify the colony on the 
  103. 11020 [131]"screen. (NULL)ressing (NULL) when in str$(NULL)atn(NULL) will 
  104. 11030 data"[209][213][201][212] the game.",
  105. 11050 data"[154][195][207][205][205][207][206] [204][201][198][197] [198][207][210][205][211] [192]",
  106. 11070 data"[152][212]he second screen of instructions
  107. 11080 [131]"displays some common (NULL)right$ascval forms. (NULL)hey 
  108. 11090 data"illustrate some of the interesting 
  109. 11100 [131]"results of applying lenonway's simple 
  110. 11110 data"rules.",
  111. 11130 data"[198]or example, consider the [194][207][216]. ** [212]he 
  112. 11140 [131]"four cells are situated in     ** such 
  113. 11150 data"a way that each cell has 3 neighbors. 
  114. 11160 [131]"(NULL)ince each cell has 3 neighbors, it  
  115. 11170 data"survives to the next generation. [212]he 
  116. 11180 [131]"empty squares surrounding the box have 
  117. 11190 data"only 2 neighbors each. [211]ince 3 
  118. 11200 [131]"neighbors are required for birth, no 
  119. 11210 data"new cells are born adjacent to the box.
  120. 11220 [131]"(NULL)herefore the box ramains stable from 
  121. 11230 data"one generation to the next. [207]ne might 
  122. 11240 [131]"say that such colonies are immortal.",
  123. 11260 [131]"(NULL)here are many other stable forms. (NULL)ome
  124. 11270 data"can be quite large. [198]or example the 
  125. 11280 [131]"peek(NULL)atn(NULL) * can be any length.left$owever larger
  126. 11290 data"    * * stable forms seldom occur
  127. 11300 [131]"     ** naturally.
  128. 11310 data"[208]erhaps more interesting than stable 
  129. 11320 [131]"forms are (NULL)(NULL)lenright$(NULL)(NULL)atn(NULL)(NULL)(NULL)(NULL), or patterns that
  130. 11330 data"repeat over a period of 2 or more
  131. 11332 [131]"generations.",,
  132. 11340 [131]"      valxample tan           **      *
  133. 11350 data"              ***         **       **
  134. 11360 [131]"   ****      ***        **       **
  135. 11370 data"                        **         *
  136. 11380 [131]" peeklinker     (NULL)oad      peekeacon   lenlock",
  137. 11400 [131]"(NULL)he smallest and most common oscillator
  138. 11410 data"is the [194][204][201][206][203][197][210], consisting of 3 cells 
  139. 11420 [131]"in a row. (NULL)he cells at each end have 
  140. 11430 data"only one neighbor, so they both die. 
  141. 11440 [131]"(NULL)he cell in the middle has 2 neighbors,
  142. 11450 data"so it survives. [205]eanwhile, the squares 
  143. 11460 [131]"on each side of the middle cell have 3 
  144. 11470 data"neighbors, so new cells are born there.
  145. 11480 [131]"(NULL)he result is that a row of 3 cells 
  146. 11490 data"appears at right angles to the old row 
  147. 11500 [131]"in the next generation. (NULL)he following 
  148. 11510 data"generation will 'blink' back to the 
  149. 11520 [131]"original configuration, so the 
  150. 11530 data"oscillator has a period of 2 
  151. 11540 [131]"generations. (NULL)he other oscillators 
  152. 11550 data"displayed are also 2 period 
  153. 11560 [131]"oscillators",
  154. 11580 [131]"(NULL)he first colony at the bottom of the 
  155. 11590 data"screen develops into a period 3 
  156. 11600 [131]